//
//  CZBaseTableViewController.swift
//  weibo24
//
//  Created by 李文峰 on 16/2/26.
//  Copyright © 2016年 fengten. All rights reserved.
//


import UIKit

class CZBaseTableViewController: UITableViewController ,CZVisitorViewDelegate {
    
    
    //父类定义一个属性,子类可以访问
    var visitor: CZVisitorView?
    
    var isLogin: Bool = CZUserViewModel.shareInstance.isLogin!
    
    override func loadView() {
        
        if CZUserViewModel.shareInstance.isLogin! {
            
            super.loadView()
        } else {
            
            showVisitorView()
            
        }
    }
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        
        
    }
    private func showVisitorView(){
        
        visitor = CZVisitorView()
        print(visitor)
        //实现代理方法
        visitor?.delegate = self
        
        
        view = visitor
        
        setupNav()
        
    }
    
    private func setupNav(){
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "didRegister")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: "didLogin")
    }
    
    
    func didRegister(){
        
        let VC = CZLoginViewController()
        
        let nav = UINavigationController(rootViewController: VC)
        
        presentViewController(nav, animated: true) { () -> Void in
            
        }
        
    }
    func didLogin(){
        
        
    }
    
    
}
